include(${CMAKE_CURRENT_LIST_DIR}/targets-tikicpulib.cmake)
set(PRODUCT_TYPE_LIST_V100_ ascend910;Ascend910A;Ascend910B;Ascend910PremiumA;Ascend910ProA;Ascend910ProB)
set(PRODUCT_TYPE_LIST_V200_ ascend610;ascend310p;Ascend310P1;Ascend310P3;Ascend310P5;Ascend310P7)
set(PRODUCT_TYPE_LIST_V220_ ascend910B1;Ascend910B1;Ascend910B2;Ascend910B2C;Ascend910B3;Ascend910B4;Ascend910B4-1;Ascend910_9391;Ascend910_9381;Ascend910_9392;Ascend910_9382;Ascend910_9372;Ascend910_9362)
set(PRODUCT_TYPE_LIST_M300_ ascend310B1;Ascend310B1;Ascend310B2;Ascend310B3;Ascend310B4)
set(PRODUCT_TYPE_LIST_M310_ ascend610Lite;Ascend610Lite)
set(PRODUCT_TYPE_LIST_M310AG_ bs9sx2aa;bs9sx2aa;bs9sx2ab)
set(PRODUCT_TYPE_LIST_M310PG_ mc61am21aa;mc61am21aa;mc61am21ab)

function(product_map str newstr)
  if("${str}" IN_LIST PRODUCT_TYPE_LIST_V100_)
    set(${newstr} "ascend910" PARENT_SCOPE)
  elseif("${str}" IN_LIST PRODUCT_TYPE_LIST_V200_)
    set(${newstr} "ascend310p" PARENT_SCOPE)
  elseif("${str}" IN_LIST PRODUCT_TYPE_LIST_V220_)
    set(${newstr} "ascend910B1" PARENT_SCOPE)
  elseif("${str}" IN_LIST PRODUCT_TYPE_LIST_M300_)
    set(${newstr} "ascend310B1" PARENT_SCOPE)
  elseif("${str}" IN_LIST PRODUCT_TYPE_LIST_M310_)
    set(${newstr} "ascend610Lite" PARENT_SCOPE)
  elseif("${str}" IN_LIST PRODUCT_TYPE_LIST_M310AG_)
    set(${newstr} "bs9sx2aa" PARENT_SCOPE)
  elseif("${str}" IN_LIST PRODUCT_TYPE_LIST_M310PG_)
    set(${newstr} "mc61am21aa" PARENT_SCOPE)
  endif()
endfunction()

foreach(product_type ${PRODUCT_TYPE_LIST_V100_} ${PRODUCT_TYPE_LIST_V200_} ${PRODUCT_TYPE_LIST_V220_} ${PRODUCT_TYPE_LIST_M300_} ${PRODUCT_TYPE_LIST_M310_} ${PRODUCT_TYPE_LIST_M310AG_} ${PRODUCT_TYPE_LIST_M310PG_})
  product_map(${product_type} product_type_series)
  if (NOT TARGET tikicpulib_${product_type_series}_interpreter)
    add_library(tikicpulib_${product_type_series}_interpreter INTERFACE)
    target_link_libraries(tikicpulib_${product_type_series}_interpreter INTERFACE tikicpulib_${product_type_series})
  endif()
  add_library(tikicpulib::${product_type} ALIAS tikicpulib_${product_type_series}_interpreter)
endforeach()
